﻿using FastORM.Applicaiton;
using FastORM.Enum;
using FastUtil.Config;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;

namespace FastCore.Test.ORM
{
    [TestClass]
    public class ListOperate
    {
        [TestMethod]
        public void FindList()
        {
            CommonDao dao = new CommonDao(DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            dao.FindList<Frame_User>("select * from Frame_User");
        }

        [TestMethod]
        public void FindListAuto()
        {
            CommonDao dao = new CommonDao(DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            dao.FindList<Frame_User>("LoginID", "Age=20", "Age");
        }

        [TestMethod]
        public void FindPageList()
        {
            CommonDao dao = new CommonDao(DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            dao.FindPageList<Frame_User>("LoginID", "Age=20", "Age", 1, 15);
        }

        [TestMethod]
        public void FindPageListAuto()
        {
            CommonDao dao = new CommonDao(DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            dao.FindPageList<Frame_User>("select LoginID from Frame_User where Age=20 order by Age desc",1, 15);
        }

        [TestMethod]
        public void FIndView()
        {
            CommonDao dao = new CommonDao(DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            dao.FindViewList("select LoginID from Frame_User where Age=20 order by Age desc");
        }

        [TestMethod]
        public void FindViewPage()
        {
            CommonDao dao = new CommonDao(DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            dao.FindViewPageList("select LoginID from Frame_User where Age=20 order by Age desc",1,15);
        }

        [TestMethod]
        public void ExecuteSQL()
        {
            CommonDao dao = new CommonDao(DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            dao.ExecuteSQL("update Frame_User set Age=33 where LoginID='yanpeng_3'");
        }

        [TestMethod]
        public void ExecuteScar()
        {
            CommonDao dao = new CommonDao(DataBaseClass.MySql, AppConfigUtil.Configuration["ConnectionStrings:Base_ConnectionString"]);
            dao.ExecuteScar("select count(1) Frame_User");
        }
    }
}
